package com.syh.billservice.controller;


import com.syh.billservice.service.IBillService;
import com.syh.bscommon.Util.UserHolder;
import com.syh.bscommon.pojo.Result;
import com.syh.bscommon.pojo.Transactions;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author syh
 * @since 2024-07-05
 */
@Tag(name = "BillController", description = "账单模块")
@RestController
@RequestMapping("/bill")
@RequiredArgsConstructor
public class BillController {
    private final IBillService billService;

    @GetMapping("/getData")
    @Operation(summary = "获取账单数据")
    public Result getData() {
        return Result.success(billService.getData(UserHolder.getUser().getCompanyId()));
    }

//    ---feign----
    @PostMapping("/addBill_success")
    @Operation(summary = "添加成功的账单")
    public Result addBill_success(@RequestBody Transactions transactions) {
        billService.addBill_success(transactions);
        return Result.success();
    }
    @PostMapping("/addBill_cansel")
    @Operation(summary = "添加取消的账单")
    public Result addBill_cansel(@RequestBody Transactions transactions) {
        billService.addBill_cansel(transactions);
        return Result.success();
    }
}
